/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.asu.cse360.service.client;

import edu.asu.cse360.model.Chef;
import edu.asu.cse360.model.Employee;
import edu.asu.cse360.model.Manager;
import edu.asu.cse360.model.OrderStatus;
import edu.asu.cse360.model.WaitPerson;
import edu.asu.cse360.service.OrderStatusService;
import edu.asu.cse360.util.EmployeeVisitor;
import java.util.Arrays;
import java.util.List;


public class OrderStatusServiceImpl implements OrderStatusService{

    private EmployeeVisitor getEditableEmployeeVisitor(){
        return new EmployeeVisitor(){

            @Override
            public Object visit(Manager manager) {
                return getStatusAllowedByManager();
            }

            @Override
            public Object visit(WaitPerson waitPerson) {
                return getStatusEditableByWaitPerson();
            }

            @Override
            public Object visit(Chef chef) {
                return getStatusEditableByChef();
            }
        };
    }

     private EmployeeVisitor getViewableEmployeeVisitor(){
        return new EmployeeVisitor(){
            @Override
            public Object visit(Manager manager) {
                return getStatusAllowedByManager();
            }

            @Override
            public Object visit(WaitPerson waitPerson) {
                return getStatusViewableByWaitPerson();
            }

            @Override
            public Object visit(Chef chef) {
                return getStatusViewableByChef();
            }
        };
    }

    @Override
    public List<OrderStatus> getEditableStatuses(Employee employee) {
        return (List<OrderStatus>) employee.accept(getEditableEmployeeVisitor());
    }

    @Override
    public List<OrderStatus> getViewableStatuses(Employee employee) {
        return (List<OrderStatus>) employee.accept(getViewableEmployeeVisitor());
    }

    @Override
    public List<OrderStatus> getStatusAllowedByManager() {
        return Arrays.asList(OrderStatus.values());
    }

    @Override
    public List<OrderStatus> getStatusViewableByWaitPerson() {
        return Arrays.asList(new OrderStatus[]{OrderStatus.DONE_COOKING});
    }

    @Override
    public List<OrderStatus> getStatusEditableByWaitPerson() {
        return Arrays.asList(new OrderStatus[]{OrderStatus.DONE_COOKING, OrderStatus.DELIVERED, OrderStatus.CANCELLED});
    }

    @Override
    public List<OrderStatus> getStatusViewableByChef() {
        return Arrays.asList(new OrderStatus[]{OrderStatus.NOT_STARTED, OrderStatus.COOKING});
    }

    @Override
    public List<OrderStatus> getStatusEditableByChef() {
        return Arrays.asList(new OrderStatus[]{OrderStatus.NOT_STARTED, OrderStatus.COOKING, OrderStatus.DONE_COOKING, OrderStatus.CANCELLED});
    }

  
 

}
